package top.techqi.base.util

import android.widget.Toast
import androidx.annotation.StringRes
import top.techqi.base.App

private var old: Toast? = null

fun toast(@StringRes resId: Int, duration: Int = Toast.LENGTH_SHORT) {
    old?.cancel()
    old = Toast.makeText(App.INSTANCE, resId, duration)
    old?.show()
}

fun toast(text: CharSequence, duration: Int = Toast.LENGTH_SHORT) {
    old?.cancel()
    old = Toast.makeText(App.INSTANCE, text, duration)
    old?.show()
}